package com.ketangpai.admin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ketangpai.admin.entity.Work;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WorkDao extends BaseMapper<Work> {
    Integer selectGroupId(Integer id);
    @Delete("DELETE FROM work WHERE course_id=#{courseId}")
    boolean deleteByCourseId(Integer courseId);
    @Select("select * from work where course_id=#{courseId}")
    List<Work> selectByCourseId(Integer courseId);

    @Insert("INSERT INTO Work (course_id, type, title, content, chapter_id, create_time, release_time, end_time, status, file, score, process, activity, is_allow_overtime_submission, is_show_score) " +
            "VALUES (#{courseId}, #{type}, #{title}, #{content}, #{chapterId}, #{createTime}, #{releaseTime}, #{endTime}, #{status}, #{file}, #{score}, #{process}, #{activity}, #{isAllowOvertimeSubmission}, #{isShowScore})")
    @Options(useGeneratedKeys = true, keyProperty = "id") // 自动获取主键并回填到实体对象
    int create(Work work);
}
